package cn.ssj.controller;

import cn.ssj.entity.Activity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017/9/4 0004.
 */
@RestController
@EnableAutoConfiguration
public class ActivityController  extends BaseController<Activity,Integer>{

    private static final Logger LOGGER= LoggerFactory.getLogger(ActivityController.class);

    @RequestMapping("/back/addActivity")
    public String add(Activity entity) {
        entity.setPicture(super.filePath);
        return super.add(entity);
    }

    @RequestMapping("/back/updateActivity")
    public String update(Activity entity) {
        entity.setPicture(super.filePath);
        return super.update(entity);
    }

    @RequestMapping("/back/deleteActivity")
    public String delete(@RequestParam("ids[]") Integer[] ids) {
        LOGGER.debug("ids="+ids);
        return super.delete(ids);
    }

    @RequestMapping("/back/queryAllActivityByPage")
    public String queryAllByPage(Integer pageNumber) {
        return super.queryAllByPage(pageNumber);
    }

    @RequestMapping("/back/activityUpload")
    public String upload(MultipartFile file, HttpServletRequest request){
        super.setLocationPath(getLocationPath()+"activity");
        super.setHandlerPath(getHandlerPath()+"activity");
        return super.upload(file,request);
    }
}
